package com.woniuxy.order.service.impl;


import com.woniuxy.commons.entity.Order;
import com.woniuxy.commons.entity.vo.ResultS;
import com.woniuxy.commons.entity.vo.ResultVo;
import com.woniuxy.order.mapper.OrderMapper;
import com.woniuxy.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @author rmw
 * @date 2020/12/3 20:07
 */
@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;

    @Override
    public ResultVo addOrder(Order order) {

        //测试接口.现在设置数据
        order.setId(1).setCustomerId(1).
                setOrderNo("1").setOrderTime(new Date())
                .setPayTime(new Date())
                .setPayStatus(1).setStartAddress("成都市郫都区犀浦镇")
                .setReceiverAddress("波士顿北岸花园").setCollectTime(new Date())
                .setValuation(new BigDecimal(1000))
                .setPayType(1).setMoney(new BigDecimal(300))
                .setGoodsWeight(200.89).setGoodsVolume(300.99)
                .setGoodsInformation("一箱桃子").setGoodsType(1).setDistance(new BigDecimal(300000));

        int flag = orderMapper.addOrder(order);

        if (flag != 0){
            ResultVo<Object> resultVo = new ResultVo<>().setResultS(ResultS.SUCCESS);
            return resultVo;
        }else {
            ResultVo<Object> resultVo = new ResultVo<>().setResultS(ResultS.FAILURE);
            return resultVo;
        }

    }
}
